/*
 * @Descripttion: 
 * @version: 
 * @Author: Ansel
 * @Date: 2020-03-24 13:24:02
 * @LastEditors: Ansel
 * @LastEditTime: 2020-04-11 20:00:46
 */

// function counts(article) {
//     article = article.trim();
//     var array = article.match(/[A-z]+/g);
//     // console.log(array);
//     article = " " + array.join("  ") + " ";
//     var max = 0, word, num = 0, maxword = "";
//     for (var i = 0; i < array.length; i++) {
//         word = new RegExp(" " + array[i] + " ", 'g');
//         console.log(word);
//         num = article.match(word).length;
//         if (num > max) {
//             max = num;
//             maxword = array[i];
//         }
//     }
//     console.log(maxword + " " + max);
// }

function counts(str){
    str = str.trim();
    var arr = str.match(/(\b(\w)+\b)/g);
    console.log(arr);
    // str = " " + arr.join(" ") + " ";
    // var max = 0,num = 0,maxword = "", word;

    // for(var i = 0;i <arr.length;i ++){
    //     word = new RegExp(" " + arr[i] + " ","g");
    //     num = str.match(word).length;
    //     if(num > max){
    //         max = num;
    //         maxword = arr[i];
    //     }
    // }
    // console.log(maxword + " " + max);
}
counts("Age has reached the end of the beginning of a word. May be guilty in his seems to passing a lot of different life became the appearance of the same day;");